package cvs;


import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class DBConnectorGSBN {

	private Connection connection;

	public void start() throws Exception {
		if (connection != null)
			return;

		try {
			Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
			connection = java.sql.DriverManager
					.getConnection(getConnectionUrl());

		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
	}

	public Connection getConnection() {
		return connection;
	}

	public void close(ResultSet rs, Statement st) {
		if (st != null)
			try {
				st.close();
			} catch (SQLException e) {
			}

		if (rs != null)
			try {
				rs.close();
			} catch (SQLException e) {
			}
	}

	public void close() {
		if (connection == null)
			return;

		try {
			connection.close();
		} catch (Exception e) {
		}
	}

	private String getConnectionUrl() {
		return "jdbc:sqlserver://105.66.103.190:1433;user=gsbn;password=seasfdc;";
	}
}
